<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
<script>

    // 构造函数
    function Person(name) {
        this.name = name;
    }
    // 为构造函数的原型对象添加继承方法
    Person.prototype.extend = function (obj) {
        for (var k in obj) {
            this[k] = obj[k]
        }
    }

    // 实例化对象
    var p1 = new Person('jack');

    var p2 = { age: 18, sex: '男' };

    //  p1想 继承 p2 的 属性和方法
    p1.extend(p2);
    console.log(p1);



</script>

</html>